package com.example.sunmiv1.adapter.good;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.sunmiv1.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class BatchSettingAdapter extends BaseAdapter {

    private List<String> list;
    private ViewHolder viewHolder;

    public BatchSettingAdapter(List<String> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.batch_setting_adapter, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.batchSettingTv.setText(list.get(position));
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.batchSetting_tv)
        TextView batchSettingTv;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
